package com.s53.crm.clue.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.s53.crm.clue.entity.Clue;
import com.s53.crm.clue.service.IClueService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 线索 前端控制器
 * </p>
 *
 * @author baomidou
 * @since 2023-04-20
 */
@RestController
@RequestMapping("/clues")
@RequiredArgsConstructor
@RefreshScope
public class ClueController {

    @Value("${server.port}")
     private int port;

    @Value("${email}")
    private String email;

    private final IClueService clueService;

    @GetMapping
    public Page<Clue> list(Clue clue,Page<Clue> page){
        System.out.println(port+","+email);
        LambdaQueryWrapper<Clue> queryWrapper
                = Wrappers.lambdaQuery(Clue.class).like(StringUtils.hasText(clue.getName()),Clue::getName,clue.getName());
        return clueService.page(page,queryWrapper);
    }

}
